<template>
    <div class="addgoods">
        <el-card class="box-card">
            <el-button type="primary" size="large" class="mb10" @click="saveData">保存</el-button>
            <el-collapse v-model="activeNames">
                <el-collapse-item class="p20" title="商品基本信息" name="1">
                    <el-row>
                        <el-col :span="12"> 商品名称:<el-input v-model="form.name" class="short"></el-input> </el-col>
                        <el-col :span="12"> 商品编号:<el-input v-model="form.code" class="short"></el-input> </el-col>
                    </el-row>

                    <el-row>
                        <el-col :span="12">
                            <span class="ml25">排序:</span><el-input v-model.number="form.levelCode" class="short"></el-input>
                        </el-col>
                        <el-col :span="12">
                            <span class="ml">标签名:</span> <el-input v-model="form.tagName" class="short"></el-input>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            商品类型:
                            <el-select v-model="form.categoryType" placeholder="请选择商品类型">
                                <el-option v-for="item in allTypeList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                            </el-select>
                        </el-col>
                        <el-col :span="12">
                            商品品牌:
                            <el-select v-model="form.brandId" placeholder="请选择商品品牌">
                                <el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                            </el-select>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            商品分类:
                            <el-select v-model="form.categoryId" placeholder="请选择商品分类">
                                <el-option v-for="item in catoryList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                            </el-select>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            支持使用满减卷:
                            <el-select v-model="form.isCountdown">
                                <el-option v-for="item in countDown" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                            </el-select>
                        </el-col>
                        <el-col :span="12">
                            支持使用粮票:
                            <el-select v-model="form.isuseSalt">
                                <el-option v-for="item in useSalt" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                            </el-select>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <span class="ml">支持使用积分:</span>
                            <el-select v-model="form.score">
                                <el-option v-for="item in countDown" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                            </el-select>
                        </el-col>
                        <el-col :span="12">
                            <span class="ml20">状态:</span>
                            <el-select v-model="form.statu">
                                <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                            </el-select>
                        </el-col>
                    </el-row>
                    <el-row> 商品描述:<el-input v-model="form.desoribe" class="descript"></el-input> </el-row>
                    <el-row>
                        <el-col :span="3"> <span>商品详情图:</span></el-col>
                        <el-col :span="3"> <img class="introduction" :src="form.introduction" alt="" /></el-col>
                        <el-col :span="6">
                            <el-button type="primary" size="large" @click="$refs.upload.click()" class="upload">上传</el-button>
                            <input type="file" name="upload" ref="upload" style="display: none" @change="uploadPic($event,'introduction')"
                        /></el-col>
                        <el-col :span="3"> <span>商品缩略图:</span></el-col>
                        <el-col :span="3"> <img class="introduction" :src="form.thumbnail" alt="" /></el-col>
                        <el-col :span="6">
                            <el-button type="primary" size="large" @click="$refs.uploadPic.click()" class="upload">上传</el-button>
                            <input type="file" name="upload" ref="uploadPic" style="display: none" @change="uploadPic($event,'thumbnail')"
                        /></el-col>
                    </el-row>
                </el-collapse-item>
                <el-collapse-item title="规格信息" name="2">
                    <el-button type="primary" class="mb10" @click="addGoodsStanders">添加规格</el-button>
                    <el-table :data="form.standardlist" style="width: 100%" border stripe>
                        <el-table-column prop="name" label="规格名称" width="180" align="center"> </el-table-column>
                        <el-table-column prop="warehouseID" label="所属仓库" width="180" align="center"> </el-table-column>
                        <el-table-column prop="level" label="排序" align="center" width="48"> </el-table-column>
                        <el-table-column prop="marketPrice" label="市场价" width="80" align="center"> </el-table-column>
                        <el-table-column prop="retailPrice" label="零售价" width="65" align="center"> </el-table-column>
                        <el-table-column prop="maxScore" label="可使用积分数" align="center" width="93"> </el-table-column>
                        <el-table-column prop="isVip" label="是否启用VIP价" width="105" align="center">
                            <template slot-scope="scope">
                                <el-checkbox :value="scope.row.isVip ? true : false"></el-checkbox>
                            </template>
                        </el-table-column>
                        <el-table-column prop="vipPrice" label="VIP价" width="77" align="center"> </el-table-column>
                        <el-table-column prop="svipPrice" label="SVIP价" align="center" width="97"></el-table-column>
                        <el-table-column prop="isShop" label="是否启用店主价" width="111" align="center">
                            <template slot-scope="scope">
                                <el-checkbox :value="scope.row.isShop ? true : false"></el-checkbox>
                            </template>
                        </el-table-column>
                        <el-table-column prop="shopPrice" label="店主价" width="77" align="center"> </el-table-column>
                        <el-table-column prop="address" label="操作" align="center" width="182">
                            <template slot-scope="scope">
                                <el-button type="primary" size="mini" @click="checkDetail(scope.row, scope.$index)">查看详情</el-button>
                                <el-button type="primary" size="mini" @click="deldeStanderd(scope.$index)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-collapse-item>
                <el-collapse-item title="商品轮播图信息" name="3">
                    <el-button type="primary" class="mb10" @click="$refs.uploads.click()">添加轮播图</el-button>
                    <input type="file" name="upload" id="upload" ref="uploads" style="display: none" @change="uploadImg" />
                    <el-table :data="form.resourcelist" style="width: 100%" border stripe>
                        <el-table-column prop="img" label="图片" align="center">
                            <template slot-scope="scope">
                                <video class="wh100" v-if="scope.row.type === 20" :autoplay="false" :src="scope.row.img"></video>
                                <img v-else :src="scope.row.img" class="wh100" alt="" />
                            </template>
                        </el-table-column>
                        <el-table-column  label="操作" align="center">
                            <template slot-scope="scope">
                                <el-button @click="deleteImgaeHandle(scope.$index)" type="primary">删除</el-button>
                            </template>
                          
                        </el-table-column>
                    </el-table>
                </el-collapse-item>
            </el-collapse>
        </el-card>

        <!-- 新增商品规格信息面板 -->
        <el-dialog title="新增商品规格信息" :visible.sync="addDialogVisible" width="50%" @close="dialogClosed">
            <el-form ref="form1" :model="form1" label-width="90px">
                <el-collapse v-model="activeNames1">
                    <el-collapse-item title="商品规格信息" name="1">
                        <el-form-item label="规格名称:">
                            <el-input v-model="form1.name" class="w200"></el-input>
                        </el-form-item>
                        <el-form-item label="所属仓库:">
                            <el-select v-model="form1.warehouseID" placeholder="请选择">
                                <el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="排序:">
                            <el-input v-model.number="form1.level" class="w200"></el-input>
                        </el-form-item>
                        <el-form-item label="市场价:">
                            <el-input v-model.number="form1.marketPrice" class="w200"></el-input>
                        </el-form-item>
                        <el-form-item label="零售价:">
                            <el-input v-model.number="form1.retailPrice" class="w200"></el-input>
                        </el-form-item>
                        <el-form-item label="可使用积分:">
                            <el-input v-model.number="form1.maxScore" class="w200"></el-input>
                        </el-form-item>
                        <el-form-item label="VIP价:">
                            <el-checkbox v-model.number="form1.isVip">是否启用</el-checkbox>
                            <el-input v-if="form1.isVip" class="w200" v-model="form1.vipPrice"></el-input>
                        </el-form-item>
                        <el-form-item label="SVIP价:">
                            <el-checkbox v-model.number="form1.isSvip">是否启用</el-checkbox>
                            <el-input v-if="form1.isSvip" class="w200" v-model="form1.svipPrice"></el-input>
                        </el-form-item>
                        <el-form-item label="店主价:">
                            <el-checkbox v-model.number="form1.isShop">是否启用</el-checkbox>
                            <el-input v-if="form1.isShop" class="w200" v-model="form1.shopPrice"></el-input>
                        </el-form-item>
                        <el-form-item label="奖金:">
                            <el-input v-model.number="form1.commission" class="w200"></el-input>
                        </el-form-item>
                        <el-form-item label="重量:">
                            <el-input v-model.number="form1.weight" class="w200"></el-input>
                        </el-form-item>
                        <el-form-item label="是否包邮:">
                            <el-checkbox v-model="form1.isParcel"></el-checkbox>
                        </el-form-item>
                        <el-form-item label="赠送积分:">
                            <el-input v-model.number="form1.giftScore" class="w200"></el-input>
                        </el-form-item>
                    </el-collapse-item>
                    <el-collapse-item title="添加赠品" name="2">
                        <el-button type="primary" class="mb10" @click="addGoodsGifts">添加</el-button>
                        <el-table :data="addGoodsList" style="width: 100%" border stripe>
                            <el-table-column prop="name" label="赠品名称" width="180"> </el-table-column>
                            <el-table-column prop="count" label="数量" width="180"> </el-table-column>
                            <el-table-column label="操作">
                                <template slot-scope="scope">
                                    <el-button type="primary" @click="editGoodsGifts(scope.row)">修改</el-button>
                                    <el-button type="primary" @click="deleGoodsGifts(scope.row)">删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-collapse-item>
                    <el-collapse-item title="添加单品" name="3">
                        <el-button type="primary" class="mb10" @click="addGoodsDanpin">添加</el-button>
                        <el-table :data="goodsDanpinLists" style="width: 100%" border stripe>
                            <el-table-column prop="img" label="缩略图" width="180">
                                <template slot-scope="scope">
                                    <img class="wh100" :src="scope.row.img" alt="" />
                                </template>
                            </el-table-column>
                            <el-table-column prop="name" label="单品名称" width="180"> </el-table-column>
                            <el-table-column prop="count" label="数量"> </el-table-column>
                            <el-table-column label="操作">
                                <template slot-scope="scope">
                                    <el-button type="primary" @click="editGoodsDanpin(scope.row)">修改</el-button>
                                    <el-button type="primary" @click="editGoodsDanpin(scope.row)">删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-collapse-item>
                </el-collapse>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="confirmAddAllStanderds">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 添加赠品面板 -->
        <el-dialog title="编辑商品赠品信息" :visible.sync="editGoodsGiftsdialogVisible" width="30%" @close="editGoodsGiftsdialogCloses">
            <el-form ref="form" :model="goodsGiftsForm" label-width="80px">
                <el-form-item label="赠品名称:">
                    <el-select v-model="goodsGiftsForm.kabawID" placeholder="请选择">
                        <el-option v-for="item in goodsGiftsList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="数量:">
                    <el-input v-model.number="goodsGiftsForm.count" class="w205"></el-input>
                </el-form-item>
            </el-form>

            <span slot="footer" class="dialog-footer">
                <el-button @click="editGoodsGiftsdialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="confirmAddGoodsGifts">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 修改赠品信息面板 -->
        <el-dialog title="编辑商品赠品信息" :visible.sync="editGoodsInfoVisible" width="30%" @closed="editGoodsInfoClosed">
            <el-form ref="form" :model="editGoodsGiftsForm" label-width="80px">
                <el-form-item label="赠品名称:">
                    <el-select v-model="editGoodsGiftsForm.kabawID" placeholder="请选择">
                        <el-option v-for="item in goodsGiftsList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="数量:">
                    <el-input v-model.number="editGoodsGiftsForm.count" class="w205"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editGoodsInfoVisible = false">取 消</el-button>
                <el-button type="primary" @click="confirmEditGoodsInfo">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 添加单品信息 -->
        <el-dialog title="添加商品单品信息" :visible.sync="editGoodsDanpinVisible" width="30%" @closed="editGoodsInfoClosed">
            <el-form ref="form" :model="editGoodsGiftsForm" label-width="80px">
                <el-form-item label="单品名称:">
                    <el-select v-model="editGoodsGiftsForm.danpinID" placeholder="请选择">
                        <el-option v-for="item in goodsDanpinMap" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="数量:">
                    <el-input v-model.number="editGoodsGiftsForm.count" class="w205"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editGoodsDanpinVisible = false">取 消</el-button>
                <el-button type="primary" @click="confirmAddGoodsDanpin">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 修改单品信息面板 -->
        <el-dialog title="编辑商品单品信息" :visible.sync="GoodsDanpinVisible" width="30%" @closed="editGoodsDanpinInfoClosed">
            <el-form ref="form" :model="goodsDanpinForm" label-width="80px">
                <el-form-item label="单品名称:">
                    <el-select v-model="goodsDanpinForm.danpinID" placeholder="请选择">
                        <el-option v-for="item in goodsDanpinMap" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="数量:">
                    <el-input v-model.number="goodsDanpinForm.count" class="w205"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="GoodsDanpinVisible = false">取 消</el-button>
                <el-button type="primary" @click="confirmEditDanpin">确 定</el-button>
            </span>
        </el-dialog>

    </div>
</template>

<script>
import { addGoods, getBrandsList, getcatoryList, getalltype, uploadPic, getWarehouseList, getGoodsGift, getGoodsDanpin } from '@/api/goods.js'

export default {
  name: 'addgoods',
  data () {
    return {
      activeNames: ['2'],
      activeNames1: ['2'],
      // 添加商品数据
      form: {
        id:'123',
        name: '',
        code: '',
        levelCode: 0,
        tagName: '',
        categoryType: 0,
        brandId: '',
        categoryId: 0,
        isCountdown: null,
        isuseSalt: null,
        score: null,
        statu: null,
        desoribe: '',
        introduction: '',
        thumbnail: '',
        standardlist: [],
        resourcelist: []
      },  
      // 规格信息数据
      form1: {
        name: '',
        warehouseID: '',
        level: 0,
        marketPrice: 0,
        retailPrice: 0,
        maxScore: 0,
        isVip: false,
        isSvip: false,
        isShop: false,
        commission: 0,
        weight: 0,
        isParcel: false,
        giftScore: 0,
        gifelist: [],
        danpinlist: [{
          danpinID: '',
          count: 0,
          demoId: 0
        }]
      },
      brandList: [],
      // 所有商品分类项
      catoryList: [],
      allTypeList: [],
      editDialogVisible: false,
      addDialogVisible: false,
      tableData: [],
      query: {
        pagenum: 1,
        pagesize: 50
      },
      pageTotal: 1,
      countDown: [
        {
          label: '支持',
          value: true
        },
        {
          label: '不支持',
          value: false
        }
      ],
      useSalt: [
        {
          label: '支持',
          value: true
        },
        {
          label: '不支持',
          value: false
        }
      ],
      useScore: [
        {
          label: '支持',
          value: true
        },
        {
          label: '不支持',
          value: false
        }
      ],
      status: [
        {
          label: '上架',
          value: true
        },
        {
          label: '下架',
          value: false
        }
      ],
      warehouseList: [],
      // 商品图片数据
      goodsDanpinMap: [],
      goodsGiftsList: [],
      editGoodsGiftsdialogVisible: false,
      goodsValue: '',
      goodsCounts: 0,
      goodsGiftsForm: {},
      // 临时添加赠品商品的数组
      addGoodsList: [],
      editGoodsGiftsForm: {
        danpinID: '',
        count: 0
      },
      editGoodsInfoVisible: false,
      editGoodsDanpinVisible: false,
      // 临时添加单品数组
      goodsDanpinLists: [],
      goodsDanpinForm: {},
      GoodsDanpinVisible: false,
      standardlist: [],
      editStanderdVisible: false,
      editStanderList: [],
      form2: {},
      editState: {
        isEdit: false,
        editIndex: 0
      }
    }
  },
  created () {
    this.getBrandsList()
    this.getallcatoryList()
    this.getAllType()
  },
  methods: {
    // 删除图片or视频
    deleteImgaeHandle(index) {
      this.form.resourcelist.splice(index, 1)
    },
    // 点击保存按钮以后就返回到商品列表页面
    async saveData () {
      const form = this.form
      const params = {
        ...this.form
      }
      console.log(form)
      const { Data } = await addGoods(params)
      console.log(Data)
      // if (Data.id === '') return
      this.$message.success('添加商品成功')
      //   this.form = {}
      this.$router.push('/commodityList')
    },

    // 获取所有品牌种类
    async getBrandsList () {
      const { Data } = await getBrandsList({
        pageIndex: 1,
        pageSize: 20,
        name: null
      })
      console.log(Data)
      this.brandList = Data.list
    },

    // 获取所有商品分类
    async getallcatoryList () {
      const { Data } = await getcatoryList()
      console.log(Data)
      this.catoryList = Data.list
    },

    // 获取所有商品类型
    async getAllType () {
      const { Data } = await getalltype()
      console.log(Data)
      this.allTypeList = Data.dictList
      // this.catoryList = Data.list
    },

    // 上传图片或者视频到服务器
    async uploadImg (e) {
      console.log('kaka', e.target.files[0].type);
      const file = e.target.files[0]
      let type = (file.type.indexOf('image') !== -1) ? 10 : 20
      if (!file.size) return
      const formData = new FormData()
      formData.append('file', file)
      formData.append('fileCategory', type)
      const { Data } = await uploadPic(formData)
      console.log(Data)
      let url = 'http://118.31.13.253:810/Upload/' + Data.url
      this.form.resourcelist.push({ url, type, level: this.form.resourcelist.length })
      this.$refs.uploads.value = ""
      console.log(this.form.img)
    },

    // 上传缩略图
    async uploadPic (e, name) {
      const file = e.target.files[0]
      if (!file.size) return
      const formData = new FormData()
      formData.append('file', file)
      formData.append('fileCategory', 10)
      const { Data } = await uploadPic(formData)
      console.log(Data)
      this.form[name] = 'http://118.31.13.253:810/Upload/' + Data.url
      console.log(this.form.thumbnail)
    },

    // 获取所有单品下拉列表
    async getGoodsDanpin () {
      const { Data } = await getGoodsDanpin()
      console.log(Data)
      this.goodsDanpinMap = Data.list
    },

    // 获取所有赠品下拉列表
    async getGoodsGift () {
      const { Data } = await getGoodsGift()
      console.log(Data)
      this.goodsGiftsList = Data.dictList
    },

    // 获取所有仓库下拉列表
    async getWarehouseList () {
      const { Data } = await getWarehouseList()
      console.log(Data)
      this.warehouseList = Data.dictList
    },

    // 点击添加规格, 显示出对话框
    addGoodsStanders () {
      console.log(11)
      this.addDialogVisible = true
      this.editState.isEdit = false
      Object.keys(this.form1).forEach(p => {
        this.$set(this.form1, p, '')
      })
      this.$set(this.form1, 'standardValue', '221')
      this.addGoodsList = []
      this.goodsDanpinLists = []


      this.getGoodsDanpin()
      this.getGoodsGift()
      this.getWarehouseList()
    },

    // 添加规格对话框关闭
    dialogClosed () {
      // this.addGoodsList = []
      // this.goodsGiftsList = []
      // this.goodsDanpinLists = []
      //
    },

    // 添加赠品信息
    addGoodsGifts () {
      this.editGoodsGiftsdialogVisible = true
    },

    // 添加赠品信息对话框关闭
    editGoodsGiftsdialogCloses () {
      this.goodsGiftsForm = {}
    },

    // 确认添加赠品
    confirmAddGoodsGifts () {
      var target = this.goodsGiftsList.find((ele) => {
        return ele.id === this.goodsGiftsForm.kabawID
      })
      const arr = { name: target.name, count: this.goodsGiftsForm.count, kabawID: this.goodsGiftsForm.kabawID }
      this.addGoodsList.push(arr)
      console.log('确认添加赠品', this.addGoodsList)
      this.editGoodsGiftsdialogVisible = false
    },

    // 修改赠品信息
    editGoodsGifts (goodsInfo) {
      this.editGoodsGiftsForm = {...goodsInfo};
      this.editGoodsGiftsForm.demoId = goodsInfo.kabawID
      console.log('修改赠品信息', this.editGoodsGiftsForm);
      this.editGoodsInfoVisible = true
    },

    // 确认修改赠品信息
    confirmEditGoodsInfo () {
      var target = this.goodsGiftsList.find((ele) => {
        return ele.id === this.editGoodsGiftsForm.kabawID
      })
      console.log('确认修改赠品信息', target, this.addGoodsList)

      const obj = this.addGoodsList.find(ele => ele.kabawID === this.editGoodsGiftsForm.demoId)

      obj.name = target.name
      obj.kabawID = target.id
      obj.count = this.editGoodsGiftsForm.count
      
      this.editGoodsInfoVisible = false
    },

    // 删除赠品信息
    deleGoodsGifts (goodsInfo) {
      const index = this.addGoodsList.findIndex((ele) => {
        return ele.name === goodsInfo.name
      })
      this.addGoodsList.splice(index, 1)
    },

    // 添加单品信息面板显示
    addGoodsDanpin () {
      this.editGoodsDanpinVisible = true
    },

    // 确认添加单品
    async confirmAddGoodsDanpin () {
      var target = this.goodsDanpinMap.find((ele) => {
        return ele.id === this.editGoodsGiftsForm.danpinID
      })

      const arr = { name: target.name, count: this.editGoodsGiftsForm.count, danpinID: this.editGoodsGiftsForm.danpinID, img: target.thumbnail }
      this.goodsDanpinLists.push(arr)
      console.log('确认添加单品', target, this.goodsDanpinLists)
      this.editGoodsDanpinVisible = false
    },

    // 修改单品信息
    editGoodsDanpin (goodsInfo) {
      this.goodsDanpinForm = {...goodsInfo}
      this.goodsDanpinForm.dempId = goodsInfo.danpinID
      this.GoodsDanpinVisible = true
      console.log('修改单品信息', this.goodsDanpinForm)
    },

    // 确认修改单品信息
    confirmEditDanpin () {
      var target = this.goodsDanpinMap.find((ele) => {
        return ele.id === this.goodsDanpinForm.danpinID
      })

      console.log('确认修改单品信息', target, this.goodsDanpinLists)

      const obj = this.goodsDanpinLists.find(ele => ele.danpinID === this.goodsDanpinForm.dempId)
      
      obj.name = target.name
      obj.danpinID = target.id
      obj.count = this.goodsDanpinForm.count
      obj.img = target.thumbnail

      this.GoodsDanpinVisible = false
    },
    // 修改赠品信息面板关闭
    editGoodsInfoClosed () {
      this.editGoodsGiftsForm = {}
    },

    // 修改单品信息面板关闭
    editGoodsDanpinInfoClosed () {
      this.GoodsDanpinVisible = false
      this.goodsDanpinForm = {}
    },

    // 确认添加或者修改规格
    confirmAddAllStanderds () {
      this.form1.gifelist = this.addGoodsList
      this.form1.danpinlist = this.goodsDanpinLists

      if (this.editState.isEdit) {
        this.$set(this.form.standardlist, this.editState.editIndex, {...this.form1})
      } else {
        this.form.standardlist.push({...this.form1})
      }
      // this.$forceUpdate()
      console.log('让我康康', this.form1, this.form)
      //  gifelist  danpinlist
      this.addDialogVisible = false
    },

    // 查看规格详情
    checkDetail (standerInfo, index) {
      this.addDialogVisible = true
      console.log('查看规格详情', standerInfo)
      this.form1 = {...standerInfo}

      this.addGoodsList = [...standerInfo.gifelist]
      this.goodsDanpinLists = [...standerInfo.danpinlist]
      this.editState.isEdit = true
      this.editState.editIndex = index
    },

    // 删除规格
    deldeStanderd (index) {
      this.form.standardlist.splice(index, 1)
    },



  }
}
</script>

<style scoped>
.descript {
    width: 800px;
}

.el-row {
    margin-bottom: 20px;
    padding: 0 30px;
}

.short {
    width: 350px;
}

.ml25 {
    margin-left: 25px;
}

.ml {
    margin-left: 13px;
}

.el-input,
.el-select {
    margin-left: 10px;
}

.ml20 {
    margin-left: 55px;
}

.mb10 {
    margin-bottom: 10px;
}

.introduction {
    width: 100px;
    height: 100px;
}
.upload {
    margin-top: 30px;
}

.w200 {
    width: 200px;
}

.w205 {
    width: 205px;
}

.wh100 {
    width: 100px;
    height: 100px;
}
</style>
